<?php
// No direct access to this file
defined('_JEXEC') or die;
 
// import the list field type
jimport('joomla.html.html');
jimport('joomla.form.formfield');
 
/**
 * NGMenu Form Field class for the NGMenu component
 */
class JFormFieldColorPicker extends JFormField
{
	/**
	 * The field type.
	 *
	 * @var		string
	 */
	protected $type = 'ColorPicker';
 
//	public function getLabel() {
//	}
 
	public function getInput() {
		
		if ($this->name == 'jform[menu_back_color_picker]'){
			$name = 'jform[menu_back_color]';
			$id = 'menu-back_color';
			$color = ($this->form->getValue('menu_back_color')=='') ? 'transparent' : $this->form->getValue('menu_back_color');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[item_back_color_normal_picker]'){
			$name = 'jform[item_back_color_normal]';
			$id = 'item-back_color_normal';
			$color = ($this->form->getValue('item_back_color_normal')=='') ? 'transparent' : $this->form->getValue('item_back_color_normal');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[item_back_color_over_picker]'){
			$name = 'jform[item_back_color_over]';
			$id = 'item-back_color_over';
			$color = ($this->form->getValue('item_back_color_over')=='') ? 'transparent' : $this->form->getValue('item_back_color_over');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[item_back_color_active_picker]'){
			$name = 'jform[item_back_color_active]';
			$id = 'item-back_color_active';
			$color = ($this->form->getValue('item_back_color_active')=='') ? 'transparent' : $this->form->getValue('item_back_color_active');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[menu_border_color_picker]'){
			$name = 'jform[menu_border_color]';
			$id = 'menu-border_color';
			$color = ($this->form->getValue('menu_border_color')=='') ? $this->value : $this->form->getValue('menu_border_color');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[item_border_color_normal_picker]'){
			$name = 'jform[item_border_color_normal]';
			$id = 'item-border_color_normal';
			$color = ($this->form->getValue('item_border_color_normal')=='') ? $this->value : $this->form->getValue('item_border_color_normal');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[item_border_color_over_picker]'){
			$name = 'jform[item_border_color_over]';
			$id = 'item-border_color_over';
			$color = ($this->form->getValue('item_border_color_over')=='') ? $this->value : $this->form->getValue('item_border_color_over');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[item_border_color_active_picker]'){
			$name = 'jform[item_border_color_active]';
			$id = 'item-border_color_active';
			$color = ($this->form->getValue('item_border_color_active')=='') ? $this->value : $this->form->getValue('item_border_color_active');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[font_color_normal_picker]'){
			$name = 'jform[font_color_normal]';
			$id = 'font-color_normal';
			$color = ($this->form->getValue('font_color_normal')=='') ? $this->value : $this->form->getValue('font_color_normal');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[font_color_over_picker]'){
			$name = 'jform[font_color_over]';
			$id = 'font-color_over';
			$color = ($this->form->getValue('font_color_over')=='') ? $this->value : $this->form->getValue('font_color_over');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[font_color_active_picker]'){
			$name = 'jform[font_color_active]';
			$id = 'font-color_active';
			$color = ($this->form->getValue('font_color_active')=='') ? $this->value : $this->form->getValue('font_color_active');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[effect_shadow_color_picker]'){
			$name = 'jform[effect_shadow_color]';
			$id = 'effect-shadow_color';
			$color = ($this->form->getValue('effect_shadow_color')=='') ? $this->value : $this->form->getValue('effect_shadow_color');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[back_color_normal_picker]'){
			$name = 'jform[back_color_normal]';
			$id = 'back-color_normal';
			$color = ($this->form->getValue('back_color_normal')=='') ? 'transparent' : $this->form->getValue('back_color_normal');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[back_color_over_picker]'){
			$name = 'jform[back_color_over]';
			$id = 'back-color_over';
			$color = ($this->form->getValue('back_color_over')=='') ? 'transparent' : $this->form->getValue('back_color_over');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[back_color_active_picker]'){
			$name = 'jform[back_color_active]';
			$id = 'back-color_active';
			$color = ($this->form->getValue('back_color_active')=='') ? 'transparent' : $this->form->getValue('back_color_active');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[border_color_normal_picker]'){
			$name = 'jform[border_color_normal]';
			$id = 'border-color_normal';
			$color = ($this->form->getValue('border_color_normal')=='') ? $this->value : $this->form->getValue('border_color_normal');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[border_color_over_picker]'){
			$name = 'jform[border_color_over]';
			$id = 'border-color_over';
			$color = ($this->form->getValue('border_color_over')=='') ? $this->value : $this->form->getValue('border_color_over');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[border_color_active_picker]'){
			$name = 'jform[border_color_active]';
			$id = 'border-color_active';
			$color = ($this->form->getValue('border_color_active')=='') ? $this->value : $this->form->getValue('border_color_active');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[fnt_color_normal_picker]'){
			$name = 'jform[fnt_color_normal]';
			$id = 'fnt-color_normal';
			$color = ($this->form->getValue('fnt_color_normal')=='') ? $this->value : $this->form->getValue('fnt_color_normal');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[fnt_color_over_picker]'){
			$name = 'jform[fnt_color_over]';
			$id = 'fnt-color_over';
			$color = ($this->form->getValue('fnt_color_over')=='') ? $this->value : $this->form->getValue('fnt_color_over');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[fnt_color_active_picker]'){
			$name = 'jform[fnt_color_active]';
			$id = 'fnt-color_active';
			$color = ($this->form->getValue('fnt_color_active')=='') ? $this->value : $this->form->getValue('fnt_color_active');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[back_color_picker]'){
			$name = 'jform[back_color]';
			$id = 'back-color';
			$color = ($this->form->getValue('back_color')=='') ? 'transparent' : $this->form->getValue('back_color');
			$style = 'background-color:'.$color;
		}
		if ($this->name == 'jform[border_color_picker]'){
			$name = 'jform[border_color]';
			$id = 'border-color';
			$color = ($this->form->getValue('border_color')=='') ? $this->value : $this->form->getValue('border_color');
			$style = 'background-color:'.$color;
		}
		
		$href = "javascript:color_picker('".$id."','".$name."');";
		$text = "&nbsp;";
		$attribs = array(
			'id' => $id,
			'style' => $style,
//			'style' => 'background-color:'.$this->value.';',
		);
	
		return JHtml::link($href, $text, $attribs);
	}
}
